if !has('nvim-0.5')
  let g:mapleader = "\<Space>"
  let g:maplocalleader = ','
  nnoremap <silent> <leader>      :<c-u>WhichKey '<Space>'<CR>
  nnoremap <silent> <localleader> :<c-u>WhichKey  ','<CR>
  vnoremap <silent> <leader> :<c-u>WhichKeyVisual '<Space>'<CR>
  call which_key#register('<Space>', "g:which_key_map")
endif
let g:which_key_map = {}




let g:which_key_map.1 = 'select window-1'
let g:which_key_map.2 = 'select window-2'
let g:which_key_map.3 = 'select window-3'
let g:which_key_map.4 = 'select window-4'
let g:which_key_map.5 = 'select window-5'
let g:which_key_map.6 = 'select window-6'
let g:which_key_map.7 = 'select window-7'
let g:which_key_map.8 = 'select window-8'
let g:which_key_map.9 = 'select window-9'
let g:which_key_map.0 = 'select window-10'

let g:which_key_map.b = { 
      \'name': '+buffer',
      \ 'b' : [':Buffers'   , 'Buffer List'],
      \ 'q' : [':Bw'        , 'remove all  buffers'],
      \ 'c' : [':Bonly'     , 'keep current buffers'],
      \}
let g:which_key_map.b.d = "Delete"


let g:which_key_map.c = { 'name': '+code' }
let g:which_key_map.c.F = { 'name': 'Fix' }
let g:which_key_map.c.f =  'Format selected' 
let g:which_key_map.c.f = "Format selected code"
let g:which_key_map.c.c = "Code  line Comment"
let g:which_key_map.c.m = "Code  block Comment"
let g:which_key_map.c.a = "Code Action"
let g:which_key_map.c.e = "Code diagnostic"

let g:which_key_map.f = { 'name': '+find'}
let g:which_key_map.f.a = 'Find Word'
let g:which_key_map.f.f = 'Find File'
let g:which_key_map.f.g = 'Find files with git'
let g:which_key_map.f.w = 'Find current word'
let g:which_key_map.f.h = 'Find history'
let g:which_key_map.f.m = 'Find most used'
let g:which_key_map.f.q = 'Find quickfix'
let g:which_key_map.f.r = "Find by farr"
let g:which_key_map.f.s = 'Find symbols'
let g:which_key_map.f.t = 'Find Tags'
let g:which_key_map.f.W = 'Find windows'
let g:which_key_map.f.l = 'Find Lines'
let g:which_key_map.f.v = 'Find visual text'



let g:which_key_map.S = { 'name':'Search'}
let g:which_key_map.h = { 'name': '+GitHunk'}

let g:which_key_map.g = {'name':"+Version control"}
let g:which_key_map.g.l = "git log "
let g:which_key_map.g.tl = "git lightlink"
let g:which_key_map.g.g = "lazygit"
let g:which_key_map.g.d = "git diff"
let g:which_key_map.g.s = "git status"
let g:which_key_map.g.a = "git staged"
let g:which_key_map.g.c = "git commit"
let g:which_key_map.g.p = "git preview"
let g:which_key_map.g.u = "git Unstage"
let g:which_key_map.g.r = "git Reset hunk"
let g:which_key_map.g.f = "git files"

let g:which_key_map.g ={
      \'name': '+git',
      \'l':[':GlLog','git log'],
      \'g' : [':FloatermNew --height=0.9 --width=0.8 lazygit', 'lazygit'],
      \'d':[':GdiffThis','git diff'],
      \'s':[':Gstatus'        ,'git status'],
      \'c':[':Git commit' ,'Git commit'],
      \}



let g:which_key_map.i = 'Vista'

let g:which_key_map.o = { 'name': '+Open'}
let g:which_key_map.o.c = 'Open personal config'
let g:which_key_map.o = 'Symbol outline'

let g:which_key_map.q = { 'name': '+quit'}
let g:which_key_map.q.q = 'Quit Buffer'
let g:which_key_map.q.w = 'Quit without save'


let g:which_key_map.t = { 'name': '+toggle'}

let g:which_key_map.s = { 'name': '+Selection'}
let g:which_key_map.s.i = 'Selection init'
let g:which_key_map.s.n = 'Selection increment'
let g:which_key_map.s.N = 'Selection decrement'
let g:which_key_map.s.c = 'Scope increment'
let g:which_key_map.s.s = 'SymbolsOutline'


let g:which_key_map.x = { 'name': '+Explorer'}
let g:which_key_map.xf =  '+File Manager'



let g:which_key_map.r = { 'name': '+Refactor'}
let g:which_key_map.re =  '+Refactor Variable'
let g:which_key_map.rf =  '+Refactor Function'
let g:which_key_map.rff =  '+Refactor Extract file'
let g:which_key_map.rr =  '+Refactor Extract()'

let g:which_key_map.w = { 'name': '+Workspace'}
let g:which_key_map.w.k = "Telescope workspace"
let g:which_key_map.p = "Commands"


let g:which_key_map.t = {
      \ 'name' : '+terminal' ,
      \ ';' : [':FloatermNew --wintype=popup --height=6'        , 'terminal'],
      \ 'f' : [':FloatermNew fzf'                               , 'fzf'],
      \ 'q' : [':FloatermKill'                                  , 'quit'],
      \ 'g' : [':FloatermNew lazygit'                           , 'git'],
      \ 'd' : [':FloatermNew lazydocker'                        , 'docker'],
      \ 'n' : [':FloatermNew node'                              , 'node'],
      \ 'N' : [':FloatermNew nnn'                               , 'nnn'],
      \ 'p' : [':FloatermNew python'                            , 'python'],
      \ 'r' : [':FloatermNew ranger'                            , 'ranger'],
      \ 't' : [':FloatermNew --wintype=popup --height=0.9 --width=0.9  zsh', 'toggle'],
      \ 'y' : [':FloatermNew ytop'                              , 'ytop'],
      \ 's' : [':FloatermNew ncdu'                              , 'ncdu'],
      \ }


  let g:which_key_map.t.c = 'Change Colorscheme'


let g:which_key_map.x = { 
      \ 'name' : '+Explorer' ,
      \'b': ['CocCommand explorer --sources=buffer+,file- --position=right --no-quit-on-open --open-action-strategy=sourceWindow','buffer'],
      \'f': ['CocCommand explorer --sources=buffer+,file+ --position=right --no-quit-on-open --open-action-strategy=sourceWindow','file+buffer'],
      \ }


